package com.kadron.dao;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;

import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.intercept.BypassInterceptors;

import com.kadron.entity.Comment;

@AutoCreate
@BypassInterceptors
@Name("commentDAO")
public class KCommentDAO extends KDAO<Comment> {

	public Comment getLast() {
		EntityManager em = getEntityManager();
		try {
			return (Comment) em.createQuery("SELECT e FROM Comment e ORDER BY e.id DESC")
			.setMaxResults(1)
			.getSingleResult();			
		} catch (NoResultException e) {
			return null;
		}
	}
	
}
